package com.cfy.mybatis.spring;

import com.cfy.mybatis.spring.domain.User;
import com.cfy.mybatis.spring.service.BarService;
import com.cfy.mybatis.spring.service.FooService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import java.util.List;

public class TestMain {
    public static void main(String[] args) {
        //String path = "src/main/java/com/cfy/mybatis/spring/config/applicationContext-sqlsession.xml";
        //ApplicationContext ac = new FileSystemXmlApplicationContext(path);
        ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:applicationContext-sqlsession.xml");
        BarService bs = (BarService)ac.getBean("barService");
        List<User> tb = bs.getAll();
        User me = bs.doSomeBusinessStuff("ui");
        System.out.println(tb);
        System.out.println(me);

        ApplicationContext acs = new ClassPathXmlApplicationContext("classpath:applicationContext-MFBean.xml");
        FooService fs = (FooService)acs.getBean("fooService");
        User you = fs.doSomeBusinessStuff("123");
        System.out.println(you);
    }
}
